package rpc

import (
	"flag"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	pay "pay/proto"
)

var (
	PayClient pay.PayClient
)

type ServerInterface interface {
	PayClient(addr *string)
}

type ServerConfig struct {
}

func NewClient() *ServerConfig {
	return &ServerConfig{}
}

func Init(addr *string) *grpc.ClientConn {
	flag.Parse()
	conn, _ := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	return conn
}

func (ServerConfig) PayClient(addr *string) {
	init := Init(addr)
	PayClient = pay.NewPayClient(init)
}
